<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8" />
<title>数据统计 - 动态表</title>
<?php include($this->c['_homes']['_viewsHome'].'/_global/_head.php');?>
</head>
<!-- BEGIN BODY -->
<body class="page-header-fixed page-sidebar-fixed">
<!-- BEGIN HEADER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/head.php');?>
<!-- END HEADER -->
<div class="clearfix"></div>
<!-- BEGIN CONTAINER -->
<div class="page-container" > 
  <!-- BEGIN HORIZONTAL MENU PAGE SIDEBAR1 -->
  <?php include($this->c['_homes']['_viewsHome'].'/_global/menu.php');?>
  <!-- END BEGIN HORIZONTAL MENU PAGE SIDEBAR --> 
  <!-- BEGIN PAGE -->
  <div class="page-content"> 
    <!-- BEGIN PAGE HEADER-->
    <div class="row">
      <div class="col-md-12"> 
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title"> 动态表</h3>
        <ul class="page-breadcrumb breadcrumb">
          <li> <i class="icon-home"></i> <a href="/manage">后台</a> <i class="icon-angle-right"></i> </li>
          <li>数据分析<i class="icon-angle-right"></i></li>
          <li>动态表</li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB--> 
      </div>
    </div>
    <!-- END PAGE HEADER--> 
    <!-- BEGIN DASHBOARD STATS -->
    <div class="row">
      <div class="col-md-12"> 
        <!-- BEGIN SAMPLE TABLE PORTLET-->
        <div class="portlet box blue">
          <div class="portlet-title">
            <div class="caption"><i class="icon-list"></i>动态表(客单价:<?=$this->data['price']?>   <!--代金券:--><?/*=$this->data['coupon_total_fee']*/?>)</div>
            <div class="tools"> <a href="javascript:;" class="collapse" ></a> </div>
          </div>
          <div class="portlet-body">
            <div class="row">
              <div class="col-md-12">
                <form method="get" role="form" action="" id="forms">
                    <div class="col-md-2">
                        <div class="input-cont">
                            <input class="form-control" name="keyword" placeholder="供应商名称/ID" value="<?= $_GET['keyword']; ?>" type="text">
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="input-cont">
                            <input class="form-control" name="goods_id" placeholder="商品ID" value="<?= $_GET['goods_id']; ?>" type="text">
                        </div>
                    </div>
                    <div class="col-md-2">
                        <select class="form-control" name="caid">
                            <option value="">全部分类</option>
                            <?php
                            if($this->cate[0]){
                                foreach($this->cate[0] as $r){
                                    if($this->data['para']['caid']>0 && $this->data['para']['caid']==$r['caid']) $slk=' selected';
                                    else $slk='';
                                    ?>
                                    <option value="<?=$r['caid'];?>"<?=$slk;?>><?=$r['name'];?></option>
                                    <?

                                    if($this->cate[$r['caid']]){
                                        foreach($this->cate[$r['caid']] as $s){
                                            if($this->data['para']['caid']>0 && $this->data['para']['caid']==$s['caid']) $slk=' selected';
                                            else $slk='';
                                            ?>
                                            <option value="<?=$s['caid'];?>"<?=$slk;?>>&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;&nbsp;<?=$s['name'];?></option>
                                            <?
                                        }
                                    }

                                }
                            }
                            ?>
                        </select>
                    </div>
                  <div class="col-md-1">
                    <input type="submit" value="统计" class="btn blue btn-block">
                  </div>
                    <div class="col-md-1">

                        <input type="botton" value="导出"  onclick="_export();" class="btn blue btn-block">
                    </div>
                </form>
              </div>
            </div>
            <div class="table-scrollable">
              <table class="table table-striped table-bordered table-hover dataTable">
                <thead>
                  <tr>
                      <th>排名</th>
                    <th>供应商ID</th>
                    <th>商品ID</th>
                    <th>商品名称</th>
                      <th>成本价</th>
                      <th>销售均价</th>
                      <th>销售数量</th>
                      <th>销售额</th>
                      <th>毛利润额</th>
                      <th>利润百分比</th>
                  </tr>
                </thead>
                <tbody>
                  <?php if ($this->data['data']){
                              $total_number = 0;
                              $total_sale_money = 0;
                              $total_gross_profit = 0;
                            foreach ($this->data['data'] as $k=>$v){
                                $total_number +=$v['goods_number'];
                                $total_sale_money +=$v['sale_money'];
                                $total_gross_profit +=$v['gross_profit'];
              	?>
                  <tr>
                      <td><?=++$k;?></td>
                    <td><?=$v['supplierid'];?></td>
                    <td><?=$v['goods_id'];?></td>
                    <td><?=$v['goods_name'];?></td>
                      <td><?=$v['purchase_price'];?></td>
                      <td><?=$v['average_price'];?></td>
                      <td><?=$v['goods_number'];?></td>
                      <td><?=$v['sale_money'];?></td>
                      <td><?=$v['gross_profit'];?></td>
                      <td><?=$v['profit_rate']*100;?>%</td>
                  </tr>
                  <?php } }?>
                  <tr>
                      <td colspan="6" style="text-align:right;">合计:</td>
                      <td ><?=$total_number;?></td>
                      <td ><?=$total_sale_money;?></td>
                      <td ><?=$total_gross_profit;?></td>
                      <td ></td>
                  </tr>
                </tbody>
              </table>
            </div>
          </div>
        </div>
        <!-- END SAMPLE TABLE PORTLET--> 
      </div>
    </div>
    <!-- END DASHBOARD STATS --> 
  </div>
  <!-- END PAGE --> 
</div>
<!-- END CONTAINER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/_footer.php');?>
<!-- BEGIN PAGE LEVEL SCRIPTS --> 
<script src="/style/assets/scripts/app.js" type="text/javascript"></script> 
<!-- END PAGE LEVEL SCRIPTS --> 
<script>
jQuery(document).ready(function() {    
   App.init();

   if (jQuery().datepicker) {
	      $('.date-picker').datepicker({
	          rtl: App.isRTL(),
	          autoclose: true
	      });
	      $('body').removeClass("modal-open"); // fix bug when inline picker is used in modal
	    } 
 
});

function _export()
{
    var obj = $('#forms').serialize();
    window.open("dynamic_export?"+obj);

}

</script> 
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>